|
/*
PHP FAQ database that uses mysql by Chuck Whitlock 3-12-2001
code based on open source code Guestbook 1.1
written by Tony Awtrey. See http://www.awtrey.com/support/dbeweb/ for more information
This is the SQL statement to create the database required for
this application.
CREATE TABLE zf_faq (
guest_id
int(4)
unsigned
zerofill
DEFAULT '0000'
NOT NULL
auto_increment,
guest_name varchar(50),
guest_email varchar(50),
guest_time timestamp(14),
guest_message text,
guest_answer text,
guest_category text,
PRIMARY KEY (guest_id)
);
*/
////////////////////////////////
// This checks to see if we need to add a faq entry.
////////////////////////////////
if (($REQUEST_METHOD=='POST')) {
mail("cwhitlock@zfmicro.com","FAQ Record Entered","Web Visitor\n$name\nEntered a FAQ");
////////////////////////////////
// This loop removed "dangerous" characters from the posted data
// and puts backslashes in front of characters that might cause
// problems in the database.
////////////////////////////////
for(reset($HTTP_POST_VARS);
$key=key($HTTP_POST_VARS);
next($HTTP_POST_VARS)) {
$this = addslashes($HTTP_POST_VARS[$key]);
$this = strtr($this, ">", " ");
$this = strtr($this, "<", " ");
$this = strtr($this, "|", " ");
$$key = $this;
}
////////////////////////////////
// This will catch if someone is trying to submit a blank
// or incomplete form.
////////////////////////////////
if ($name && $email && $message ) {
////////////////////////////////
// This is the meat of the query that updates the zf_faq table
////////////////////////////////
$query = "INSERT INTO zf_faq ";
$query .= "(guest_id, guest_name, ";
$query .= "guest_email, guest_time, guest_message, guest_answer, guest_category) ";
$query .= "values(0000,'$name','$email',NULL,'$message','$answer','$category')";
mysql_pconnect("localhost","faquser","hackitup")
or die("Unable to connect to SQL server");
mysql_select_db("zf_faq_db") or die("Unable to select database");
mysql_query($query) or die("Insert Failed!");
} else {
////////////////////////////////
// If they didn't include all the required fields set a variable
// and keep going.
////////////////////////////////
$notall = 1;
}
}
$name = NULL;
$email = NULL;
$message = NULL;
$answer = NULL;
$category = NULL;
?>
Add A New FAQ? |
if ($notall == 1) { ?>
Please fill in all of the information you can:
} ?>
[ top
]
|
|